Skip to content

fix: env field in config, PostHog no-op in dev/test#415

Merged
manojbajaj95 merged 1 commit into
mainfrom
fix/env-config-posthog-test-mode
Jun 10, 2026
Merged

fix: env field in config, PostHog no-op in dev/test#415
manojbajaj95 merged 1 commit into
mainfrom
fix/env-config-posthog-test-mode

Conversation

@manojbajaj95

Copy link
Copy Markdown
Collaborator

Summary

  • Adds env: Literal["prod", "dev", "test"] to AuthsomeConfig (read from AUTHSOME_ENV, defaults to "prod") — process-wide, not server-only
  • ServerConfig.analytics_enabled now short-circuits when env != "prod", making PostHog a strict no-op in dev and test
  • tests/conftest.py sets AUTHSOME_ENV=test at module level and in the _disable_analytics autouse fixture
  • .github/workflows/python-test.yml adds AUTHSOME_ENV: test (defence-in-depth) and timeout-minutes: 10 so runaway jobs fail in 10 min instead of hitting the 6-hour GitHub limit

Root cause (CI hang in #409)

The PostHog SDK's shutdown() joins a consumer thread that makes real HTTP connections. Even without an API key, enable_exception_autocapture=True installs process-wide hooks that can leave non-daemon threads alive after the test suite finishes. pytest-timeout's signal method (SIGALRM) cannot interrupt C-level thread waits, so pytest hung until GitHub cancelled the job at 6 hours.

Test plan

  • uv run pytest — 340 passed in ~4s
  • uv run ruff check — clean
  • uv run ty check — clean

🤖 Generated with Claude Code

…ents

Adds `env: Literal["prod", "dev", "test"]` to `AuthsomeConfig` (read from
`AUTHSOME_ENV`) so the runtime environment is a first-class config concern
shared across client and server.

Gates `analytics_enabled` on `env == "prod"` in `ServerConfig` so PostHog
is never initialised in dev or test — preventing the background consumer
thread from blocking pytest process exit and causing CI jobs to hang until
the 6-hour GitHub Actions timeout.

Test suite now sets `AUTHSOME_ENV=test` at module level and in the
`_disable_analytics` autouse fixture. The CI workflow also sets it as
defence-in-depth and adds `timeout-minutes: 10` so runaway jobs fail fast.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@manojbajaj95 manojbajaj95 merged commit dd6f8d2 into main Jun 10, 2026
4 checks passed
@manojbajaj95 manojbajaj95 deleted the fix/env-config-posthog-test-mode branch June 10, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant